package domain.entities;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Budget entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "budget", catalog = "bms")
public class Budget implements java.io.Serializable {

	// Fields

	private Integer id;
	private ProtocoloCompromisopais protocoloCompromisopais;
	private Date received;
	private Float amountSbwinitial;
	private Date dateRevised;
	private Float amountSbwrevised;
	private Date dateFinal;
	private Float amountSbwfinal;

	// Constructors

	/** default constructor */
	public Budget() {
	}

	/** minimal constructor */
	public Budget(ProtocoloCompromisopais protocoloCompromisopais) {
		this.protocoloCompromisopais = protocoloCompromisopais;
	}

	/** full constructor */
	public Budget(ProtocoloCompromisopais protocoloCompromisopais,
			Date received, Float amountSbwinitial, Date dateRevised,
			Float amountSbwrevised, Date dateFinal, Float amountSbwfinal) {
		this.protocoloCompromisopais = protocoloCompromisopais;
		this.received = received;
		this.amountSbwinitial = amountSbwinitial;
		this.dateRevised = dateRevised;
		this.amountSbwrevised = amountSbwrevised;
		this.dateFinal = dateFinal;
		this.amountSbwfinal = amountSbwfinal;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne()
    @LazyCollection(LazyCollectionOption.FALSE)
    @JoinColumns( {
			@JoinColumn(name = "protocolo_compromisopaisprotocoloid", referencedColumnName = "protocoloid", nullable = false),
			@JoinColumn(name = "protocolo_compromisopaiscompromisopaisid", referencedColumnName = "compromisopaisid", nullable = false) })
	public ProtocoloCompromisopais getProtocoloCompromisopais() {
		return this.protocoloCompromisopais;
	}

	public void setProtocoloCompromisopais(
			ProtocoloCompromisopais protocoloCompromisopais) {
		this.protocoloCompromisopais = protocoloCompromisopais;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "received", length = 10)
	public Date getReceived() {
		return this.received;
	}

	public void setReceived(Date received) {
		this.received = received;
	}

	@Column(name = "amountSBWInitial", precision = 12, scale = 0)
	public Float getAmountSbwinitial() {
		return this.amountSbwinitial;
	}

	public void setAmountSbwinitial(Float amountSbwinitial) {
		this.amountSbwinitial = amountSbwinitial;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "dateRevised", length = 10)
	public Date getDateRevised() {
		return this.dateRevised;
	}

	public void setDateRevised(Date dateRevised) {
		this.dateRevised = dateRevised;
	}

	@Column(name = "amountSBWRevised", precision = 12, scale = 0)
	public Float getAmountSbwrevised() {
		return this.amountSbwrevised;
	}

	public void setAmountSbwrevised(Float amountSbwrevised) {
		this.amountSbwrevised = amountSbwrevised;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "dateFinal", length = 10)
	public Date getDateFinal() {
		return this.dateFinal;
	}

	public void setDateFinal(Date dateFinal) {
		this.dateFinal = dateFinal;
	}

	@Column(name = "amountSBWFinal", precision = 12, scale = 0)
	public Float getAmountSbwfinal() {
		return this.amountSbwfinal;
	}

	public void setAmountSbwfinal(Float amountSbwfinal) {
		this.amountSbwfinal = amountSbwfinal;
	}

    public void copyDatesAndAmountsFrom(Budget budget){
        this.dateRevised = budget.dateRevised;
        this.dateFinal = budget.dateFinal;
        this.received = budget.received;
        this.amountSbwfinal = budget.amountSbwfinal;
        this.amountSbwinitial = budget.amountSbwinitial;
        this.amountSbwrevised = budget.amountSbwrevised;
    }
}